#include <Windows.h>
#include "ClntCom_i.h"
#include "ServCom_i.h"


int main()
{
    HRESULT hr;
    IPersistPropertyBag* pPersistBag;
    IPropertyBag* pBag;
    IPStorage* pSimple;

    hr = CoInitialize(0);
    hr = CoCreateInstance(CLSID_PStorage, NULL, CLSCTX_INPROC_SERVER, IID_IPersistPropertyBag, (void**)&pPersistBag);
    hr = CoCreateInstance(CLSID_PBag, NULL, CLSCTX_INPROC_SERVER, IID_IPropertyBag, (void**)&pBag);

    hr = pPersistBag->QueryInterface(IID_IPStorage, (void**)&pSimple);


    //BSTR bstr = SysAllocString(L"This is Test");
    //hr=pSimple->put_bString(bstr);

    //hr=pPersistBag->Save(pBag, TRUE, TRUE);


    BSTR bstr;

    hr = pSimple->get_bString(&bstr);

    hr = pPersistBag->Load(pBag, NULL);

    SysFreeString(bstr);
    hr = pSimple->get_bString(&bstr);


    pSimple->Release();
    pPersistBag->Release();
    pBag->Release();
    CoUninitialize();

    return 0;
}